import Vue from 'vue'
import App from './App.vue'
import conf from './config'

//引入图标
// import './assets/icon/iconfont.css'

// 引入路由
import router from "./routes.js";

/*页面标题插件*/
import VueWechatTitle from 'vue-wechat-title';
Vue.use(VueWechatTitle);

// mint-ui
import 'mint-ui/lib/style.css'; /*no*/
import { Toast, Indicator } from 'mint-ui';
Vue.prototype.$mint_ui = {
	Toast:Toast,
	Indicator:Indicator,
};

//全局挂载api
import api from './api/account';
Vue.prototype.$api = api;

//全局配置
Vue.prototype.$conf = conf;


//获取当前页面链接？后面的参数
var getUrlPara=function (str){
	var LocString=String(window.document.location.href);
	var rs=new RegExp("(^|)"+str+"=([^&]*)(&|$)","gi").exec(LocString),tmp;
	if(tmp=rs)return tmp[2];
	return false;
}
Vue.prototype.$getUrlPara = getUrlPara;


//引入进度条
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
NProgress.start();

//当路由进入前
router.beforeEach((to, from , next) => {
	// 每次切换页面时，调用进度条
   NProgress.start();
   // 这个一定要加，没有next()页面不会跳转的。这部分还不清楚的去翻一下官网就明白了
	next();
});

//当路由进入后：关闭进度条
router.afterEach(() => {  
   // 在即将进入新的页面组件前，关闭掉进度条
   NProgress.done()
})

//初始化
new Vue({
  el: '#app',
  router,  // 注入到根实例中
  render: h => h(App)
})
